// Copyright (c) 2008 Matthew Johnson
// Licensed under the MIT License (see license.txt)
package actionml.core {
	import actionml.Global;
	
	import flash.xml.XMLNodeType;
	
	public class XMLMethods {
		public static function initialize() {
			Global.initializeExtension(XMLMethods, XML);
		}
		public static var instanceMethods:Object = {
			getAttributes: function() {
				var r:* = {};
				var a:XMLList = this.attributes();
				for (var i:int = 0; i < a.length(); i++) { 
					var value:* = this.attribute(a[i].name());
					if (value == "false") {
						value = false;
					} else {
						if (isNaN(Number(value))) {
							if (Number["isHex"](value.toString())) {
								value = Number["parseHex"](value);
								trace("hex value: " + value)
							} else {
								value = String(value);
							}
						} else {
							value = Number(value)
						}
					}
					r[a[i].name().toString()] = value;
				}
				return r;
			}
		};
	}
}